<template>
  <div class="My">
    <div class="user">
      <img src="@/assets/bg.png" alt="" />
      <div class="box">
        <div class="tou">
          <img src="@/assets/avatar.png" alt="" />
        </div>
        <p>{{ uname }}</p>
        <van-button type="primary" @click="godw">去登录</van-button>
      </div>
    </div>
    <div class="flag">
      <van-grid clickable :column-num="3" :border="false">
        <van-grid-item icon="star-o" text="我的收藏" to="/collect" />
        <van-grid-item icon="wap-home-o" text="我的出租" to="/rent" />
        <van-grid-item icon="clock-o" text="看房记录" />
        <van-grid-item icon="credit-pay" text="成为房主" />
        <van-grid-item icon="contact" text="个人资料" />
        <van-grid-item icon="service-o" text="联系我们" />
      </van-grid>
    </div>
    <div class="join"><img src="@/assets/join.png" alt="" /></div>
  </div>
</template>
<script>
import { getUserInfo } from '@/api/user'
export default {
  name: 'My',
  data () {
    return {
      uname: ''
    }
  },
  async created () {
    const data = await getUserInfo()
    console.log(data)
    this.uname = data.body.nickname
  },
  methods: {
    godw () {
      if (!this.uname) this.$router.push('/login')
      else{this.$router.push('/login')}
    }
  }
}
</script>

<style lang="less" scoped>
.My {
  // padding: 0 10px;
  background: #fff;
  height: 100%;
  .flag {
    margin-top: 15px;
  }
  .join {
    padding: 10px;
  }
}
.user {
  min-height: 300px;
  position: relative;
  .box {
    position: absolute;
    background: #fff;
    width: 75%;
    height: 55%;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 10px 3px #ddd;
    margin: 50px auto 0;
    padding: 0 20px;
    text-align: center;
    font-size: 13px;
    .tou {
      background-color: #fff;
      position: relative;
      transform: translateY(-50%);
      border-radius: 50%;
      width: 70px;
      height: 70px;
      border: 5px px solid #f5f5f5;
      display: inline-block;
      box-shadow: 0 2px 2px #bdbdbd;
      img {
        margin-top: 5px;
        height: 60px;
        width: 60px;
        // width: 100%;
        // border-radius: 50%;
      }
    }
  }
}
img {
  width: 100%;
  // height: 80px;
  // border-radius: 50%;
  overflow: hidden;
}
</style>
